package com.xh.springCloud.hystrix.client;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import org.springframework.stereotype.Service;

/**
 * Created by xuhao on 2016/11/23.
 */
@Service
public class ClientService {


    /**
     * 客户端调用微服务方法，存在经常失败的可能性
     * @return
     */
    @HystrixCommand(fallbackMethod = "fallback", commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "10000")
    })
    public String test(){
//        throw new RuntimeException("调用微服务失败");
        return "success";
    }

    /**
     * 降级方法
     * @return
     */
    private String fallback(){
        return "fallback";
    }
}
